<template>
	<view>
		<view class="topBg flex-dc-ac-jc">
			<image src="../../static/img/contranctSuccess.png" mode="widthFix" style="height: auto;"></image>
			<text class="f50 cfff">签约成功！</text>
		</view>
		<view class="con">
			<view class="list bgfff">
				<view class="item flex-ac-jb" v-if="dataObj.oneUrl">
					<text>{{dataObj.oneName}}</text>
					<view class="saveBtn" @tap="downLoad(dataObj.oneUrl)">下载</view>
				</view>
				<view class="item flex-ac-jb" v-if="dataObj.twoUrl">
					<text>{{dataObj.twoName}}</text>
					<view class="saveBtn" @tap="downLoad(dataObj.twoUrl)">下载</view>
				</view>
				<view class="item flex-ac-jb" v-if="dataObj.threeUrl">
					<text>{{dataObj.threeName}}</text>
					<view class="saveBtn" @tap="downLoad(dataObj.threeUrl)">下载</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
               dataObj:{}
			}
		},
		onLoad(options) {
			console.log('zzz',options.customerNum);
			console.log('ddd',this.getUrlParam('customerNum', location.href));
			let customerNum = options.customerNum ? options.customerNum : this.getUrlParam('customerNum', location.href)
			let productCode = options.productCode ? options.productCode : this.getUrlParam('productCode', location.href)
			this.$http.get(`/api/h5/g/downloadUrl`, {
				customerNum,
				productCode
			}).then(res => {
				if (res.data.code == 200) {
					let result = res.data.data
					console.log('合同签约查询', result)
                    this.dataObj = result
				} else {
					this.$u.msg(res.data.msg)
				}
			})
		},
		methods: {
			getUrlParam(name, httpCode) {
				var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
				let url = httpCode
				console.log(url);
				if (url.includes('?')) {
					let urlParam = url.split('?')[1].split('#')[0].match(reg)
					console.log(urlParam);
					if (urlParam !== null) return unescape(urlParam[2])
					return null;
				}
			},
			downLoad(url){
				window.location.href=url
			}
		}
	}
</script>

<style lang="less">
	.topBg {
		background: #0096ff;
		padding: 30rpx 0;

		image {
			width: 500rpx;
		}
	}

	.con {
		padding: 20rpx;

		.list {
			border-radius: 15rpx;

			.item {
				padding: 30rpx 40rpx;
				border-bottom: 1px solid #f6f7f8;

				.saveBtn {
					width: 120rpx;
					height: 60rpx;
					border-radius: 10rpx;
					margin-left: 20rpx;
				}
			}
		}
	}

	.backHome {
		margin: 50rpx 50rpx 0 50rpx;
		border-radius: 15rpx;
	}
</style>